package lifeOfAFish;

/**
 * Class TimeManager
 */
public class TimeManager {

	float m_time = 0.0f;
	float m_step = 0.2f;
	
	//
	// Fields
	//

	static private TimeManager instance;

	//
	// Constructors
	//
	public TimeManager() {

		
	};

	/**
	 * Update the time
	 */
	float hour = 16;
	float minute = 00;
	public void update()
	{
		minute += m_step;
//		minute = m_time - (int)m_time;
		if(minute >= 60)
		{
			hour++;
			minute -= 60;
		}
		if(hour >= 24){
			hour = 0.0f;
		}
		
//		System.out.println(hour + " " + minute);
	}
	
	/**
	 * Get dawn intensity
	 */
	public float dawnIntensity()
	{
		float start = 7.0f, end = 9.0f;
		if (hour >= start && hour < end){
			float intensity = ((hour-start)*60+minute)/((end-start)*60);
			System.out.println("dawn " + intensity);
			return intensity;
		}
		else return 0.0f;
	}
	
	/**
	 * Get dusk intensity
	 */
	public float duskIntensity()
	{
		float start = 17.0f, end = 19.0f;
		if (hour >= start && hour < end){
			float intensity = ((hour-start)*60+minute)/((end-start)*60);
			System.out.println("dusk " + intensity);
			return intensity;
		}
		return 0.0f;
	}


	/**
	 * Singleton Access
	 * 
	 * @return Instance
	 */
	public static synchronized TimeManager getInstance() {
		if (instance == null) {
			instance = new TimeManager();
		}
		return instance;
	}

	//
	// Other methods
	//

}
